package com.hellobike.haxing.modules.order.job;

import com.hellobike.haxing.common.constant.CacheConstant;
import com.hellobike.haxing.common.util.RedisUtil;
import com.hellobike.haxing.modules.order.service.IOrderBService;
import com.hellobike.haxing.modules.order.service.IOrderService;
import com.hellobike.haxing.modules.wms.facade.WmsSyncFacade;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * 已揽收、已提货7天订单完成
 * 无售后-订单完成
 * 有售后-无售后申请的订单
 */
@Slf4j
@Component
public class FinishOrderJob {

    @Autowired
    private IOrderBService orderBService;
    @Autowired
    private RedisUtil redisUtil;

    @Scheduled(fixedDelay = 20 * 60 * 1000)
    public void execute() {
        Object result = redisUtil.get(CacheConstant.ORADER_FINISH_JOB);
        log.info("订单完成定时器：{}",result);
        if (result != null) {
            return;
        }
        redisUtil.set(CacheConstant.ORADER_FINISH_JOB, 1, 600);
        log.info("==订单完成开始执行==");
        orderBService.updateFinishOrder();
    }
}
